<!--
 * @Author: Allen
 * @Date: 2021-03-15 10:18:32
 * @Description: 抱怨身处黑暗，不如提灯前行。愿你在自己存在的地方，成为一束光，照亮世界的一角
 * @LastEditTime: 2021-03-19 16:10:43
 * @LastEditors: Allen
 * @FilePath: \dmocdms_webend\src\components\se\appointmentConfirm\cancelExplain.vue
 * @Additional: 附加类容
-->
<template>
  <section>
    <el-dialog
      v-dialogDrag
      :visible="explainVisible"
      width="50%"
      :append-to-body="true"
      :close-on-click-modal="false"
      @close="close"
    >
      <DialogHeader
        slot="title"
        title="索赔单审核意见"
        :style-type="$store.state.app.dialogType"
      />
      <el-form ref="form" :model="form" label-width="150px">
        <el-form-item label="退回/拒绝原因：">
          <el-input
            v-model="cancelReason"
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          v-for="comp in tableButtons1"
          :key="comp.compKey"
          :type="comp.type"
          @click="comp.clickEvent"
        >{{ comp.text }}</el-button>
      </div>
    </el-dialog>
  </section>
</template>

<script>
import DialogHeader from '@/components/dialogHeader'
export default {
  name: 'CalcelExplain',
  components: {
    DialogHeader
  },
  props: {
    explainVisible: {
      type: Boolean
    },
    reserveOrderCode: {
      type: String,
      require: true
    },
    updateControlId: {
      type: String
    },
    carSeriesCode:{
      type: String
    },
     carSeriesCn:{
      type: String
    },
  },
  data() {
    return {
      form: {},
      cancelReason: '',
      tableButtons1: [
        {
          compKey: 'btnKey0',
          type: 'primary',
          size: 'small',
          clickEvent: () => this.save(),
          text: '退回/拒绝'
        },
        {
          compKey: 'btnKey1',
          type: '',
          size: 'small',
          clickEvent: () => this.close(),
          text: '取消'
        }
      ]
    }
  },
  methods: {
    close() {
      this. cancelReason="",
      this.$emit('closePop', 1)
    },
    save() {
      if (!this.cancelReason) return this.$message('原因为必填项')
      const cancelApi = {
        apiUrl: '/mp/e3sh/aftersale/QueryAndConfirmAppointmentService/cancel.do',
        variables: {
          reserveOrderCode: this.reserveOrderCode,
          cancelReason: this.cancelReason,
          updateControlId: this.updateControlId,
          carSeriesCode:this.carSeriesCode,
          carSeriesCn:this.carSeriesCn
        }
      }
      this.$requestAPI(cancelApi, '').then((response) => {
        console.log(response)
        if (response.result == 1) {
          this.$message({
            message: response.msg,
            type: 'warn',
            duration: 1000
          })
          this. cancelReason="",
          this.$emit('selectTable')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
